import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
// import { Switch } from 'ant-design-vue';
// import { setRoleStatus } from '/@/api/demo/system';
// import { useMessage } from '/@/hooks/web/useMessage';
// import { getDictTypeListApi } from '/@/api/admin/dict';
// import { DICT } from '/@/enums/dict';
import ToolbarInput from './ToolbarInput.vue';

export const columns: BasicColumn[] = [
  {
    title: '字典编码',
    dataIndex: 'dictType',
  },
  {
    title: '名称',
    dataIndex: 'description',
  },
  {
    title: '字典类型',
    dataIndex: 'systemFlag',
    customRender: ({ record }) => {
      const test = Number(record.systemFlag) === 0 ? '业务类' : '系统类';
      return h('div', test);
    },
  },
  {
    title: '类别说明',
    dataIndex: 'remarks',
  },

  {
    title: '创建时间',
    dataIndex: 'createTime',
  },
  // {
  //   title: '备注',
  //   dataIndex: 'postDesc',
  // },
];

export const columnsItem: BasicColumn[] = [
  {
    title: '排序',
    dataIndex: 'sortOrder',
    width: 60,
  },
  // {
  //   title: '字典编码',
  //   dataIndex: 'dictType',
  //   width: 220,
  // },
  {
    title: '显示名称',
    dataIndex: 'label',
  },
  {
    title: '描述',
    dataIndex: 'description',
  },
  {
    title: '字典值',
    dataIndex: 'value',
    width: 100,
  },

  {
    title: '备注信息',
    dataIndex: 'remarks',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'dictType',
    label: '字典编码',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    label: '名称',
    field: 'description',
    component: 'Input',
    colProps: { span: 5 },
  },
  // {
  //   field: 'group',
  //   label: '所属分组',
  //   component: 'ApiSelect',
  //   componentProps: {
  //     allowClear: false,
  //     api: getDictTypeListApi,
  //     labelField: 'label',
  //     valueField: 'intValue',
  //     params: {
  //       type: DICT.DICT_GROUP,
  //     },
  //     getPopupContainer: () => document.body,
  //   },
  //   colProps: { span: 5 },
  // },
];

export const formSchema: FormSchema[] = [
  // {
  //   field: 'group',
  //   label: '所属分组',
  //   required: true,
  //   component: 'ApiSelect',
  //   colProps: { span: 12 },
  //   componentProps: {
  //     allowClear: false,
  //     api: getDictTypeListApi,
  //     labelField: 'label',
  //     valueField: 'intValue',
  //     params: {
  //       type: DICT.DICT_GROUP,
  //     },
  //     getPopupContainer: () => document.body,
  //   },
  // },
  {
    field: 'dictType',
    label: '字典编码',
    required: true,
    component: 'Input',
  },
  {
    field: 'description',
    label: '名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'systemFlag',
    component: 'Select',
    label: '字典类型',
    required: true,

    componentProps: {
      allowClear: false,
      options: [
        {
          label: '业务类',
          value: '0',
          key: '0',
        },
        {
          label: '系统类',
          value: '1',
          key: '1',
        },
      ],
    },
  },
  {
    label: '备注信息',
    field: 'remarks',
    component: 'InputTextArea',
  },
];

export const formItemSchema: FormSchema[] = [
  // {
  //   field: 'dictType',
  //   label: '字典编码',
  //   required: true,
  //   component: 'Input',
  //   dynamicDisabled: true,
  //   colProps: { span: 12 },
  // },
  {
    field: 'value',
    label: '数据值',
    required: true,
    component: 'Input',
    colProps: { span: 12 },
  },
  {
    field: 'label',
    label: '显示名称',
    required: true,
    component: 'Input',
    colProps: { span: 12 },
    itemProps: {
      autoLink: false,
    },
    render({ model, field }) {
      return (
        <ToolbarInput allowClear vModel={[model[field], 'data']} placeholder="请输入显示名称" />
      );
    },
  },
  {
    field: 'description',
    label: '描述',
    required: true,
    component: 'Input',
    colProps: { span: 12 },
    itemProps: {
      autoLink: false,
    },
    render({ model, field }) {
      return <ToolbarInput allowClear vModel={[model[field], 'data']} placeholder="请输入描述" />;
    },
  },
  {
    field: 'sortOrder',
    label: '排序',
    required: true,
    component: 'InputNumber',
    colProps: { span: 12 },
  },
  {
    label: '备注信息',
    field: 'remarks',
    component: 'InputTextArea',
    colProps: { span: 24 },
  },
];
